---@class GT.playerGroup 玩家组
---@field playerGroup RoleGroup 玩家组
GT.playerGroup = class()

---@class playerGroup_data 玩家组
---@field playerGroup RoleGroup 玩家组

---@param data playerGroup_data
function GT.playerGroup:ctor(data)
    self.playerGroup = data.playerGroup
end

--- 玩家组是否存在
---@param role_group GT.playerGroup 玩家组
---@return Bool
function GT.playerGroup.role_group_is_exist(role_group)
    return game_api.role_group_is_exist(role_group.playerGroup)
end

--- 获取某玩家敌对玩家组
---@param role GT.player 玩家
---@return GT.playerGroup
function GT.playerGroup.get_enemy_ids_by_role(role)
    ---@type playerGroup_data
    local data = {
        playerGroup = game_api.et_enemy_ids_by_role(role.player)
    }
    return new(GT.playerGroup, data)
end

--- 获取获胜玩家组
---@return GT.playerGroup
function GT.playerGroup.get_victorious_role_ids()
    ---@type playerGroup_data
    local data = {
        playerGroup = game_api.get_victorious_role_ids()
    }
    return new(GT.playerGroup, data)
end

--- 获取失利玩家组
---@return GT.playerGroup
function GT.playerGroup.get_defeated_role_ids()
    ---@type playerGroup_data
    local data = {
        playerGroup = game_api.get_defeated_role_ids()
    }
    return new(GT.playerGroup, data)
end

--- 所有玩家
---@return GT.playerGroup
function GT.playerGroup.get_all_role_ids()
    ---@type playerGroup_data
    local data = {
        playerGroup = game_api.get_all_role_ids()
    }
    return new(GT.playerGroup, data)
end

---将玩家组转lua table 对象
---@return GT.player[]
function GT.playerGroup:pick()
    ---@type GT.player[]
    local lua_table = {}
    for i = 1, python_len(self.playerGroup) do
        local iter_player = python_index(self.playerGroup, i - 1)
        table.insert(lua_table, GT.player.get_by_int(iter_player))
    end
    return lua_table
end

--- 阵营所有玩家
---@param camp Camp 阵营对象
---@return GT.playerGroup
function GT.playerGroup.get_role_ids_by_camp(camp)
    ---@type playerGroup_data
    local data = {
        playerGroup = game_api.get_role_ids_by_camp(camp)
    }
    return new(GT.playerGroup, data)
end

--- 特定类型玩家
---@param role_type Int32 玩家类型
---@return GT.playerGroup
function GT.playerGroup.get_role_ids_by_type(role_type)
    ---@type playerGroup_data
    local data = {
        playerGroup = game_api.get_role_ids_by_type(role_type)
    }
    return new(GT.playerGroup, data)
end

--- 同盟玩家
---@param role GT.player 玩家
---@return GT.playerGroup
function GT.playerGroup.get_ally_ids_by_role(role)
    ---@type playerGroup_data
    local data = {
        playerGroup = game_api.get_role_ids_by_type(role.player)
    }
    return new(GT.playerGroup, data)
end

--- 将玩家添加到玩家组
---@param role GT.player 玩家
function GT.playerGroup:add_role_to_group(role, group)
    game_api.add_role_to_group(role.player, self.playerGroup)
end

--- 玩家组中删除玩家
---@param role Role 玩家
function GT.playerGroup:rem_role_from_group(role)
    game_api.rem_role_from_group(role.player, self.playerGroup)
end
